from flask import Flask
from flask_sqlalchemy import SQLAlchemy
import redis
from flask_session import Session
from flask_cors import CORS
from settings import Config, DevelopmentConfig
from settings import get_log

# 记录日志
get_log(DevelopmentConfig)

app = Flask(__name__)

app.config.from_object(DevelopmentConfig)

# 加载配置类之后在创建db
db = SQLAlchemy(app)

# 创建一个redis实例
redis_store = redis.Redis(host=DevelopmentConfig.CUSTOM_REDIS_IP, port=DevelopmentConfig.CUSTOM_REDIS_PORT)

# 让 app 使用 Session
Session(app)

# CORS
CORS(app)


from project.apps.home import home_blueprint
app.register_blueprint(home_blueprint)

from project.apps.user import user_blueprint
app.register_blueprint(user_blueprint)